<template>
  <div>
    <nav-bar class="nav-bar">
      <div slot="left" class="left" @click="goBack">
        <img src="~assets/images/detail/left.png" alt="" />
      </div>
      <ul class="center-bar" slot="center">
        <li
          v-for="(item, index) in navData"
          :key="index"
          class="item-bar"
          @click="handelItem(index)"
          :class="{ active: index === currentIndex }"
        >
          {{ item }}
        </li>
      </ul>
    </nav-bar>
  </div>
</template>

<script>
import NavBar from "../../../components/common/navBar/NavBar";
export default {
  data() {
    return {
      info: {},
      navData: ["商品", "参数", "评论", "推介"],
      currentIndex: 0,
    };
  },
  components: {
    NavBar,
  },
  methods: {
    handelItem(index) {
      this.currentIndex = index;
    },
    goBack(){
      this.$router.go(-1)
    }
  },
};
</script>
<style scoped>
.nav-bar {
  background: white;
  color: black;
  position: relative;
  z-index: 10;
  /* line-height: 20px; */
}
.left {
  display: flex;
  align-items: center;
  height: 100%;
  padding-left: 10px;
}
.left img {
  width: 20px;
  height: 20px;
  /* background: red;
    flex: 1; */
}
.center-bar {
  display: flex;
  align-items: center;
  text-align: center;

}
.item-bar {
  flex: 1;
}
.active {
  color: rgb(245, 110, 162);
}
</style>